/***************************************************************
*  Name:  dsa
*	   
*  Synopsis:  Digital Signature ALgortihm DSA 
*    	    
*  Description:
*     	    
*  History:
*      	         pascal - Feb 5, 2012:  Created.
*
***************************************************************/

/* $Id$ */

#include <stdio.h>
#include "dsa.h"


void dsa_sign(dsa_params * params, mpz_t private_key, unsigned int *hash, int hash_len, dsa_signature *signature)
{
        /*
         * k = (c%(q-1))+1
         * r = (g^k % p) % q
         * z = hash(message) truncated to sizeof(q)
         * s  ((k^-1 %q)*(z+xr))%q
         *
         * x = private key
         * g,p,q part of the public key
         * r,s : are the signature.
         * c = 
         */
        
}

void dsa_verify(mpz_t public_key, unsigned int *hash, int hash_len, dsa_signature *signature)
{
        /*
         * w = s^-1 % q
         * z =  hash(message), truncated to sizeof(q)
         * u1 = (zw) %q
         * u2 = (rw) %q
         * v = ((g^u1 y^u2) %p) %q
         *
         * test v == r
         *
         * y public key.
         */
}


void dsa_generate_params(dsa_params *params, mpz_t private_key, mpz_t public_key)
{
  // generate params.g, params.p, params.q, private_key, public_key

}
